package db.day04;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @Author Gan
 * @Date 2021/5/26 14:30
 * @Description:
 */
public class DemoMyConnectionPool {
    public static void main(String[] args) throws SQLException {
        //获得一个连接
        Connection connection = MyConnectionPool.getConnection();
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery("select * from postgraduate");
        while (resultSet.next()){
            System.out.println("研究生学号："+resultSet.getInt("sno"));
            System.out.println("研究生姓名："+resultSet.getString("sname"));
            System.out.println("研究生性别："+resultSet.getString("gender"));
            System.out.println("研究生入学日期："+ resultSet.getString("entrydate"));
            System.out.println("==========================");
        }
        resultSet.close();
        statement.close();
        //返回这个使用完的连接
        MyConnectionPool.returnConnection(connection);

    }
}
